﻿using MediatR;
using System.CJL.API.Application.Command.StorageCommand;
using System.CJL.Domain;
using System.CJL.Domain.DTO;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.StorageCommandHandler
{
    public class StorageListCommandHandler:IRequestHandler<StorageListCommand, PageDTO<Storage>>
    {
        IStorageRepository _storageRepository;

        public StorageListCommandHandler(IStorageRepository storageRepository)
        {
            _storageRepository = storageRepository;
        }

        public async Task<PageDTO<Storage>> Handle(StorageListCommand request, CancellationToken cancellationToken)
        {
            var lut = new PageDTO<Storage>();
            var qouer = (from stor in await _storageRepository.GetAll() where stor.IsDelete == false select stor);
            lut.plist = qouer.ToList();
           return lut;
        }
    }
}
